﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace dzs.Web.badness
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int bid=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(bid);
				}
			}
		}
			
	private void ShowInfo(int bid)
	{
		dzs.BLL.badness bll=new dzs.BLL.badness();
		dzs.Model.badness model=bll.GetModel(bid);
		this.lblbid.Text=model.bid.ToString();
		this.txtbdesp.Text=model.bdesp;
		this.txtbdate.Text=model.bdate.ToString();
		this.txtbspot.Text=model.bspot;
		this.txtproject.Text=model.project;
		this.txtmaterial.Text=model.material;
		this.txtsid.Text=model.sid.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtbdesp.Text.Trim().Length==0)
			{
				strErr+="bdesp不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtbdate.Text))
			{
				strErr+="bdate格式错误！\\n";	
			}
			if(this.txtbspot.Text.Trim().Length==0)
			{
				strErr+="bspot不能为空！\\n";	
			}
			if(this.txtproject.Text.Trim().Length==0)
			{
				strErr+="project不能为空！\\n";	
			}
			if(this.txtmaterial.Text.Trim().Length==0)
			{
				strErr+="material不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txtsid.Text))
			{
				strErr+="sid格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int bid=int.Parse(this.lblbid.Text);
			string bdesp=this.txtbdesp.Text;
			DateTime bdate=DateTime.Parse(this.txtbdate.Text);
			string bspot=this.txtbspot.Text;
			string project=this.txtproject.Text;
			string material=this.txtmaterial.Text;
			int sid=int.Parse(this.txtsid.Text);


			dzs.Model.badness model=new dzs.Model.badness();
			model.bid=bid;
			model.bdesp=bdesp;
			model.bdate=bdate;
			model.bspot=bspot;
			model.project=project;
			model.material=material;
			model.sid=sid;

			dzs.BLL.badness bll=new dzs.BLL.badness();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","List.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("List.aspx");
        }
    }
}
